package com.bw.z.mvp.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.blankj.utilcode.util.LogUtils;
import com.bw.z.R;
import com.bw.z.db.DBManager;
import com.bw.z.db.UserTable;
import com.bw.z.db.UserTableDao;

import java.util.List;

public class SetActivity extends AppCompatActivity {

    private DBManager dbManager;
    private UserTableDao userTableDao;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set);
    }

    public void signOut(View view) {
        dbManager = new DBManager(view.getContext());
        userTableDao = dbManager.getDaoSession().getUserTableDao();
        if (userTableDao.loadAll().size() != 0) {
            dbManager.getDaoSession().deleteAll(UserTable.class);
        }
        LogUtils.json(userTableDao.loadAll());
        Intent intent = new Intent();
        intent.setAction("set");
        sendBroadcast(intent);
        finish();
    }

}